﻿namespace WMS6.BLL
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using WMS6.Common;
    using WMS6.DataEntity;
    using WMS6.IDAL;
    using WMS6.DALFactory;

    public class PrintReportBLL
    {
        private static readonly ICommonMethodDA commonMethod = DataAccess.CreateCommonMethod();
        private static readonly ICycleCountCriteriaDA cycleCountCriteriaDA = DataAccess.CreateCycleCountCriteriaDA();
        private List<string> dataBaseID;
        private InboundHelper inboundHelper;
        private static readonly IOrderDetailDA orderDetailDA = DataAccess.CreateOrderDetailDA();
        private static readonly IOrdersDA ordersDA = DataAccess.CreateOrdersDA();
        private static readonly IPackDA packDA = DataAccess.CreatePackDA();
        private static readonly IPrintControlDA printControlDA = DataAccess.CreatePrintControlDA();
        private static readonly IPrintReportDA printReportDA = DataAccess.CreatePrintReportDA();
        private PrintReportsInfo printReportsInfo;
        private static readonly IPhysicalRequestDA RequestDA = DataAccess.CreatePhysicalRequestDA();
        private static readonly IPhysicalTagDA TagDA = DataAccess.CreatePhysicalTagDA();

        public PrintReportBLL()
        {
            this.inboundHelper = new InboundHelper();
            this.printReportsInfo = null;
        }

        public PrintReportBLL(string currentWH)
        {
            this.inboundHelper = new InboundHelper();
            this.printReportsInfo = null;
            if (!string.IsNullOrEmpty(currentWH))
            {
                this.dataBaseID = commonMethod.GetDataBaseID(currentWH);
                if (this.dataBaseID == null)
                {
                    PublicMethod.GetInstance().ShowAlertMessage("C001");
                }
            }
            else
            {
                PublicMethod.GetInstance().ShowAlertMessage("C002");
            }
        }

        public PrintReportBLL(PrintReportsInfo tempPrintReportsInfo)
        {
            this.inboundHelper = new InboundHelper();
            this.printReportsInfo = null;
            if (!string.IsNullOrEmpty(tempPrintReportsInfo.CurrentWH))
            {
                this.dataBaseID = commonMethod.GetDataBaseID(tempPrintReportsInfo.CurrentWH);
                if (this.dataBaseID == null)
                {
                    PublicMethod.GetInstance().ShowAlertMessage("C001", tempPrintReportsInfo.UserLanguage);
                }
                else
                {
                    this.printReportsInfo = new PrintReportsInfo();
                    this.printReportsInfo = tempPrintReportsInfo;
                    this.printReportsInfo.WhLoignID = this.dataBaseID[0];
                }
            }
            else
            {
                PublicMethod.GetInstance().ShowAlertMessage("C002", tempPrintReportsInfo.UserLanguage);
            }
        }

        public DataSet GetEncasingDetailNote(string orderID, string containerID)
        {
            return printReportDA.GetEncasingDetailTitle(orderID, containerID, this.printReportsInfo);
        }

        public DataSet GetEncasingNote(string orderID)
        {
            return printReportDA.GetEncasingNote(orderID, this.printReportsInfo);
        }

        public DataSet GetPringShippingOrderByShippingID(string shippingID, List<string> pickDetailIDs)
        {
            return printReportDA.GetShippingOrderRptInfoByID(shippingID, pickDetailIDs, this.printReportsInfo);
        }

        public DataSet GetPrintAllocation(string receiptID)
        {
            return printReportDA.GetPrintAllocation(receiptID, this.printReportsInfo);
        }

        public DataSet GetPrintBatchOutboundListReport(string waveID, string orderIDs)
        {
            return printReportDA.GetPrintBatchOutboundListReport(waveID, orderIDs, this.printReportsInfo);
        }

        public DataSet GetPrintBatchPickAdviceReport(string waveID)
        {
            return printReportDA.GetPrintBatchPickAdviceReport(waveID, this.printReportsInfo);
        }

        public DataSet GetPrintBatchPickAdviceReportByOrders(string orderIDs)
        {
            return printReportDA.GetPrintBatchPickAdviceReportByOrders(orderIDs, this.printReportsInfo);
        }

        public DataSet GetPrintBatchPickListReportInfo(string OrderID)
        {
            return printReportDA.GetPrintBatchPickListReportInfo(OrderID, this.printReportsInfo);
        }

        public DataSet GetPrintBatchShippingOrderReport(string waveID, string orderIDs)
        {
            return printReportDA.GetPrintBatchShippingOrderReport(waveID, orderIDs, this.printReportsInfo);
        }

        public DataSet GetPrintCarNoticeSet(string orderID)
        {
            return printReportDA.GetPrintCarNoticeSet(orderID, this.printReportsInfo);
        }

        public DataSet GetPrintCommoditySignoff(string orderID)
        {
            return printReportDA.GetPrintCommoditySignoffInfo(orderID, this.printReportsInfo);
        }

        public DataSet GetPrintCycleCountByReleaseID(string releaseID)
        {
            return printReportDA.GetPrintCycleCountByReleaseID(releaseID, this.printReportsInfo);
        }

        public DataSet GetPrintImportReceipt(string receiptID)
        {
            return printReportDA.GetPrintImportReceipt(receiptID, this.printReportsInfo);
        }

        public DataSet GetPrintInventoryAdjustment(string adjustmentID)
        {
            return printReportDA.GetPrintInventoryAdjustment(adjustmentID, this.printReportsInfo);
        }

        public DataSet GetPrintKittingWorkReportInfo(string OrderID)
        {
            return printReportDA.GetPrintKittingWorkReportInfo(OrderID, this.printReportsInfo);
        }

        public DataSet GetPrintLoading(string loadID)
        {
            return printReportDA.GetPrintLoading(loadID, this.printReportsInfo);
        }

        public DataSet GetPrintLpnLabelInfo(string Lpns)
        {
            return printReportDA.GetPrintLpnLabelInfo(Lpns, this.printReportsInfo);
        }

        public DataSet GetPrintMergePickListReportInfo(string waveID, string descr, string detailID)
        {
            return printReportDA.GetPrintMergePickListDetailReportInfo(detailID, this.printReportsInfo);
        }

        public DataSet GetPrintOrderMovementInfo(string movementID)
        {
            return printReportDA.GetPrintOrderMovementInfo(movementID, this.printReportsInfo);
        }

        public DataSet GetPrintOutboundInfo(string OrderID)
        {
            return printReportDA.GetPrintOutboundInfo(OrderID, this.printReportsInfo);
        }

        public DataSet GetPrintOutboundListInfo(string OrderID)
        {
            return printReportDA.GetPrintOutboundListInfo(OrderID, this.printReportsInfo);
        }

        public DataSet GetPrintPaymentBillByMovementID(string movementID)
        {
            return printReportDA.GetPrintPaymentBillByMovementID(movementID, this.printReportsInfo);
        }

        public DataSet GetPrintPaymentBillByOrderID(string orderID)
        {
            return printReportDA.GetPrintPaymentBillByOrderID(orderID, this.printReportsInfo);
        }

        public DataSet GetPrintPaymentBillByReceiptID(string receiptID)
        {
            return printReportDA.GetPrintPaymentBillByReceiptID(receiptID, this.printReportsInfo);
        }

        public DataSet GetPrintPCMaintenance(string PhysicalRequestID, string OnlyNonEmptyLoc)
        {
            DataSet ds = printReportDA.GetPrintPCMaintenanceList(PhysicalRequestID, OnlyNonEmptyLoc, this.printReportsInfo);
            if ((ds != null) && (ds.Tables.Count > 0))
            {
                string status = ds.Tables[0].Rows[0]["STATUS"].ToString();
                if ((status == PhysicalRequestStatus.New) || (status == PhysicalRequestStatus.CReleased))
                {
                    RequestDA.UpdatePhysicalRequestStatus(PhysicalRequestID, PhysicalRequestStatus.Printed, this.printReportsInfo.WhLoignID);
                    TagDA.UpdatePhysicalTagStatus(PhysicalRequestID, PhysicalRequestStatus.Printed, this.printReportsInfo.WhLoignID);
                }
            }
            return ds;
        }

        public DataSet GetPrintPCReview(string PhysicalRequestID, string OnlyNonEmptyLoc)
        {
            DataSet ds = printReportDA.GetPrintPCReview(PhysicalRequestID, OnlyNonEmptyLoc, this.printReportsInfo);
            if ((ds != null) && (ds.Tables.Count > 0))
            {
                string status = ds.Tables[0].Rows[0]["STATUS"].ToString();
                if ((status == PhysicalRequestStatus.New) || (status == PhysicalRequestStatus.CReleased))
                {
                    RequestDA.UpdatePhysicalRequestStatus(PhysicalRequestID, PhysicalRequestStatus.Printed, this.printReportsInfo.WhLoignID);
                    TagDA.UpdatePhysicalTagStatus(PhysicalRequestID, PhysicalRequestStatus.Printed, this.printReportsInfo.WhLoignID);
                }
            }
            return ds;
        }

        public DataSet GetPrintPickDivideReport(string waveID, string orderIDs)
        {
            return printReportDA.GetPrintPickDivideReport(waveID, orderIDs, this.printReportsInfo);
        }

        public DataSet GetPrintPickListReportInfo(string OrderID)
        {
            return printReportDA.GetPrintPickListReportInfo(OrderID, this.printReportsInfo);
        }

        public DataSet GetPrintPickReportInfo(string OrderID)
        {
            return printReportDA.GetPrintPickReportInfo(OrderID, this.printReportsInfo);
        }

        public DataSet GetPrintPickWorkReportInfo(string OrderID)
        {
            return printReportDA.GetPrintPickWorkReportInfo(OrderID, this.printReportsInfo);
        }

        public DataSet GetPrintPurchaseOrderInfo(string poID)
        {
            return printReportDA.GetPrintPurchaseOrderInfo(poID, this.printReportsInfo);
        }

        public DataSet GetPrintPutAwayReportInfo(string receiptID, List<string> taskDetailIDs)
        {
            return printReportDA.GetPrintPutawayReportInfo(receiptID, taskDetailIDs, this.printReportsInfo);
        }

        public DataSet GetPrintQCReportInfo(string receiptID)
        {
            return printReportDA.GetPrintQCReportInfo(receiptID, this.printReportsInfo);
        }

        public DataSet GetPrintReceiptHistoryInfo(string receiptID)
        {
            return printReportDA.GetPrintReceiptHistoryInfo(receiptID, this.printReportsInfo);
        }

        public DataSet GetPrintReceiptInfo(string receiptID)
        {
            return printReportDA.GetPrintReceiptInfo(receiptID, this.printReportsInfo);
        }

        public DataSet GetPrintReceivableBillByMovementID(string movementID)
        {
            return printReportDA.GetPrintReceivableBillByMovementID(movementID, this.printReportsInfo);
        }

        public DataSet GetPrintReceivableBillByOrderID(string orderID)
        {
            return printReportDA.GetPrintReceivableBillByOrderID(orderID, this.printReportsInfo);
        }

        public DataSet GetPrintReceivableBillByReceiptID(string receiptID)
        {
            return printReportDA.GetPrintReceivableBillByReceiptID(receiptID, this.printReportsInfo);
        }

        public DataSet GetPrintSalesOrderInfo(string orderID)
        {
            return printReportDA.GetPrintSalesOrderInfo(orderID, this.printReportsInfo);
        }

        public DataSet GetPrintWaveShipmentReport(string waveIDs)
        {
            return printReportDA.GetPrintWaveShipmentReport(waveIDs, this.printReportsInfo);
        }
    }
}

